package com.njitzx.controller;

import com.njitzx.entity.vo.MenuVO;
import com.njitzx.entity.vo.Result;
import com.njitzx.service.MemberService;
import com.njitzx.service.MenuService;
import com.njitzx.util.BaseContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "菜单表接口")
@RestController
@RequestMapping("/menus")
public class MenuController {

    @Autowired
    MenuService menuService;

    @ApiOperation("左侧用户菜单")
    @GetMapping
    public Result getMenu() {
        Integer userId = BaseContext.getCurrentId(); //通过threadlocal拿到userId
        List<MenuVO> menuVOS = menuService.getMenusByUserId(userId);

        return Result.success(menuVOS);
    }
}
